﻿@using HPIT.RentHouse.DTO
@model PermissionsDTO
@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_Layout1.cshtml";
}

<article class="cl pd-20">
    <form action="@Url.Action("Edit_Per","Permissions")" method="post" class="form form-horizontal" id="form-admin-add">
        @Html.HiddenFor(model => model.Id)
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限名字：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Name" placeholder="" id="Name" name="Name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>权限描述：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Description" placeholder="" id="Description" name="Description">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
@section footScript{
    <script type="text/javascript">
        $(function () {
            $('.skin-minimal input').iCheck({
                checkboxClass: 'icheckbox-blue',
                radioClass: 'iradio-blue',
                increaseArea: '20%'
            });

            $("#form-admin-add").validate({
                rules: {
                    Name: {
                        required: true,
                        maxlength: 16
                    },
                    Description: {
                        required: true,
                    },
                },
                //不能为空
                messages: {
                    Name: {
                        required: "不能为空",
                        maxlength: "输入长度最多是16个字符串"
                    },
                    Description: {
                        required: "不能为空",
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    $(form).ajaxSubmit({
                        success: function (data) {
                            console.log(data)
                            if (data.State == 1) {
                                parent.location.reload();
                            } else {
                                layer.msg(data.ErrorMessage, { icon: 2 })
                            }
                        }
                    });
                }
            })
        })
    </script>
}

